-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade Astral to 2.2 #48573
Upgrade Astral to 2.2 #48573
Conversation
Tests adjusted to match the output of the new Astral 2.2. |
@@ -152,10 +155,10 @@ async def test_norway_in_june(hass): | |||
|
|||
assert dt_util.parse_datetime( | |||
state.attributes[sun.STATE_ATTR_NEXT_RISING] | |||
) == datetime(2016, 7, 25, 23, 23, 39, tzinfo=dt_util.UTC) | |||
) == datetime(2016, 7, 24, 22, 59, 45, 689645, tzinfo=dt_util.UTC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(copy-paste of relevant information from above)
The new Astral both produces different times and provides times down to the MS level. To deal with that the tests need to be re-written. Tests were written to match old Astrals less accurate data.
I got confirmation here:
#48282 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference looks to be more than 24 hours. So it shouldn't just be the milliseconds accuracy. Can you explain the other differences that would result in this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, this confused and stumped me for some time. Long story short, since the day goes on for more than a month, it seems many calculators are in disagreement as to the date of sunrise and sunset here.
For example:
https://www.timeanddate.com/sun/norway/tromso?month=6&year=2016
https://www.esrl.noaa.gov/gmd/grad/solcalc/table.php?lat=69.6&lon=18.8&year=2016
It seems both versions of astral are wrong, but is entirely dependant on the altitude specified, as the sun barely makes it to the 7 degree inclination required for it to be considered a sunrise, the more altitude you add the sooner time the sunrise is ( in this case even by almost a day! ) The new version of Astral uses the location of the user ( via hass config ) to calculate times, as such the sunrise and sunset times will vary because of that. You will see I made edits to the tests in many places to specify a location's elevation ( based off the elevation at that latitude and longitude of coordinates ) as to increase the accuracy of apparent sunrise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
This is a breaking change since the API of both the astral package and |
It's not a breaking change for users, but it's a breaking change for custom integration developers. |
Breaking change
get_astral_location
andget_location_astral_event_next
to include anelevation
parameter. Also the return value ofget_astral_location
has changed to a tuple including elevation.The reason for the breaking change is that we've updated the
astral
library used in Home Assistant Core from version 1.10.1 to version 2.2. Please see the changelog ofastral
for further details:https://github.com/sffjunkie/astral/blob/master/ChangeLog.md#22---2020-05-20
Proposed change
Updates the Astral Package to 2.2. This assists users running home-assistant on distros with dependancies attached to a more recent version of Astral such as seen in Arch linux
https://github.com/sffjunkie/astral/blob/master/ChangeLog.md#22---2020-05-20
sffjunkie/astral@1.10.1...2.2
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests:
Differences between Astral 2.2 and 1.10.1
sffjunkie/astral@1.10.1...2.2
See Version Changes at this link for main differences
https://astral.readthedocs.io/en/latest/index.html